package com.tz.farmer.controller;


import com.smartPark.msframe.result.ResultEx;
import com.tz.farmer.model.FarmerNutrition;
import com.tz.farmer.service.NutritionService;
import com.tz.farmer.so.BaseSo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @description: 营养推荐（h5）
 * @name BusinessController
 * @author: xhj
 * @date: 2021/7/13
 * @version V1.0
 */
@RestController
@RequestMapping("nutrition")
@Api(value = "营养推荐（h5）", tags = "营养推荐（h5）控制器")
public class NutritionController {

    private static Logger logger = LoggerFactory.getLogger(NutritionController.class);

    @Resource
    NutritionService nutritionService;


    /**
     * @description:  查询营养推荐信息
     * @name businessInfo
     * @author: xhj
     * @date: 2021/7/13 11:35
     * @version V1.0
     */
    @ApiOperation("查询营养推荐信息")
    @GetMapping("nutritionInfo")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "flag", value = "农/渔（0：农  1：渔）", defaultValue = ""),
    })
    public ResultEx getNutritionInfo(BaseSo baseSo) {
        try {
            return nutritionService.getNutritionInfo(baseSo);
        }catch (Exception e){
            logger.error("营养推荐获取失败",e);
            return ResultEx.builder().makeFailedResult("营养推荐获取失败");

        }
    }

    /**
     * @description:  查询营养推荐详情
     * @name nutritionDetailInfo
     * @author: xhj
     * @date: 2021/7/13 11:35
     * @version V1.0
     */
    @ApiOperation("查询营养推荐详情")
    @GetMapping("nutritionDetailInfo")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "营养推荐id", defaultValue = ""),
    })
    public ResultEx getNutritionDetailInfo(FarmerNutrition farmerNutrition) {
        try {
            return nutritionService.getNutritionDetailInfo(farmerNutrition);
        }catch (Exception e){
            logger.error("营养推荐详情获取失败",e);
            return ResultEx.builder().makeFailedResult("营养推荐详情获取失败");

        }
    }

}
